<link rel="stylesheet" href="../css/login.css?v=1.0.1">
<style>
    .login-bg {
        padding: 10px 0;
        width: 100vw;
    }

    .wrap {
        padding-top: 20vw;
    }
</style>

<div class="login-bg">
    <div class="wrap">
        <ul class="input-wrap">
            <li class="li phone">
                <span>登录账号</span>
                <input type="text" placeholder="输入你的手机号">
            </li>
            <li class="li pwd">
                <span>登录密码</span>
                <input type="password" placeholder="输入你的密码">
            </li>
        </ul>
        <button class="new-btn" onclick="submit()">登录</button>
    </div>
</div>

<script>
   
    // 登录
    function submit() {
        var phone = $.trim($('.phone input').val());
        var pwd = $.trim($('.pwd input').val());
        if (!checkMobile(phone)) {
            _msg('请输入正确的手机号');
            return;
        }
        if (!(pwd && pwd.length >= 6)) {
            _msg('密码不能为空并且不少于6位')
            return;
        }
        if (!phone) {
            _msg('手机号未填写');
            return;
        }
        var obj = {
            phone: phone,
            password: pwd
        };
        _log(JSON.stringify(obj))
        _ajax('login.php', function (ret, err) {
            _log(JSON.stringify(ret))
            _log(JSON.stringify(err))
            if (ret && ret.code == 200) {
                _msg('登录成功');
                setCookie('userid', ret.result.id);
                setCookie('sex', ret.result.sex);
                //设置上线
                setOnline(1)
                _hone();
            } else {
                _msg(ret.msg);
            }
        }, {
            phone: phone,
            password: pwd
        })
    }
</script>